package algorithm.swordoff;

import algorithm.leetcode.ListNode;

/**
 * 反转链表
 * 牢记 3个变量 4行代码
 */

public class SQ24 {

    public ListNode reverseList(ListNode head) {
        ListNode prev = null, curr = head, next = null;

        while (curr != null) {
            next = curr.next;
            curr.next = prev;
            prev = curr;
            curr = next;
        }
        return prev;
    }

}
